package com.stm.bi.web;

import com.stm.bi.model.Chart;
import com.stm.bi.model.DatatablePage;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import com.stm.bi.dto.query.PolicyEvolveDatatableQuery;
import com.stm.bi.dto.query.PolicyEvolveDetailChartQuery;
import com.stm.bi.dto.query.PolicyEvolveTotalChartQuery;
import com.stm.bi.service.PolicyEvolveService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author zhouyuanpeng
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/policyEvolve")
@Module("方针占比推移")
public class PolicyEvolveController {
    @Resource
    private PolicyEvolveService policyEvolveService;

    @GetMapping(value = "/totalChart")
    @RestApi(name = "合计图表查询", author = "zpy", idx = 1, permission = "paisi:policyEvolve:query")
    public Response<Chart<List<List<Object>>>> queryTotalChart(PolicyEvolveTotalChartQuery query) {
        return policyEvolveService.queryTotalChart(query);
    }

    @GetMapping(value = "/detailChart")
    @RestApi(name = "具体政策图表查询", author = "zpy", idx = 2, permission = "paisi:policyEvolve:query")
    public Response<Chart<List<List<Object>>>> queryDetailChart(PolicyEvolveDetailChartQuery query) {
        return policyEvolveService.queryDetailChart(query);
    }


    @GetMapping(value = "/table")
    @RestApi(name = "推移表", author = "zyp", idx = 3, permission = "paisi:policyEvolve:query")
    public Response<DatatablePage> queryDatatable(PolicyEvolveDatatableQuery query) {
        return policyEvolveService.queryDatatable(query);
    }

    @GetMapping(value = "/export")
    @RestApi(name = "导出", author = "zyp", idx = 4, permission = "paisi:policyEvolve:export")
    public void export(HttpServletResponse response, PolicyEvolveDatatableQuery query) throws IOException {
        policyEvolveService.export(response, query);
    }

}
